<template>
  <quill-editor
    ref="quillEditor"
    :style="getCustomeStyle"
    :content="getEditorContent"
  >
  </quill-editor>
</template>
<script>
import { quillEditor } from "vue-quill-editor";

export default {
  name: "Editor",
  components: {
    quillEditor,
  },
  props: {
    customeStyle: {
      type: [String, Object],
      default: () => "",
    },
    editorContent: {
      type: String,
      default: () => "",
    },
    contentType: {
      type: String,
      default: () => "text",
    },
  },
  computed: {
    getCustomeStyle: {
      get() {
        return this.customeStyle;
      },
    },
    getEditorContent: {
      get() {
        return this.editorContent;
      },
    },
  },
  methods: {
    // 编辑文本内容
    getContent(contentType) {
      if (contentType && contentType !== "") {
        this.contentType = contentType;
      }
      if (this.contentType === "text") {
        const content = this.$refs.quillEditor.quill.getText();
        return content;
      } else {
        const content = this.$refs.quillEditor.quill.root.innerHTML;
        return content;
      }
    },
  },
};
</script>
<style lang="scss" scoped></style>
